#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
char graph[10][10] = {
        {'A', 'B', 'C', 'D'},
        {'E', 'F', 'G', '/'},
        {'I', 'J', '/', 'L'},
        {'M', 'N', '/', 'P'},

};
int sx = 0, sy = 0;//起点的坐标
int book[10][10];//book[i][j]=1 代表地图上map[i][j]已经访问过
int n = 4;
int fx[4][2] = {{0,  1},
                {1,  0},
                {0,  -1},
                {-1, 0}};

struct Node {
    int x, y;
} que[2000];
int head = 0, tail = -1;

void bfs(int sx, int sy) {

    head = 0, tail = -1;//队列初始化
    que[++tail] = {sx, sy};//起点入队
    book[sx][sy] = 1;//入队标记，避免重复访问
    while (tail >= head) {
        Node node = que[head];
        //当前准备出队的元素未访问的所有领域都加入队列末尾
        for (int i = 0; i < 4; i++) {
            int nx = node.x + fx[i][0];
            int ny = node.y + fx[i][1];
            if (nx < 0 || nx >= n | ny < 0 || ny >= n
                || graph[nx][ny] == '/'
                || book[nx][ny] == 1)
                continue;
            que[++tail] = {nx, ny};//起点入队
            book[nx][ny] = 1;//入队标记，避免重复访问
        }
        cout << graph[node.x][node.y] << " ";//输出
        head++;

    }

}


int main() {
    bfs(0, 0);
    return 0;
}